#!/bin/bash

echo "========================================"
echo "AopApplication 测试套件运行脚本"
echo "========================================"
echo

echo "正在运行完整测试套件..."
echo

# 运行完整测试套件
echo "[1/6] 运行完整测试套件..."
mvn test -Dtest=AopApplicationTestSuite
if [ $? -ne 0 ]; then
    echo "测试套件运行失败！"
    exit 1
fi

echo
echo "[2/6] 运行事务失效专项测试..."
mvn test -Dtest=TransactionFailureScenarioTest
if [ $? -ne 0 ]; then
    echo "事务失效测试运行失败！"
    exit 1
fi

echo
echo "[3/6] 运行服务层单元测试..."
mvn test -Dtest=MyServiceTest
if [ $? -ne 0 ]; then
    echo "服务层测试运行失败！"
    exit 1
fi

echo
echo "[4/6] 运行控制器测试..."
mvn test -Dtest=MyControllerTest
if [ $? -ne 0 ]; then
    echo "控制器测试运行失败！"
    exit 1
fi

echo
echo "[5/6] 运行依赖服务测试..."
mvn test -Dtest=AnotherServiceTest
if [ $? -ne 0 ]; then
    echo "依赖服务测试运行失败！"
    exit 1
fi

echo
echo "[6/6] 运行集成测试..."
mvn test -Dtest=AopApplicationIntegrationTest
if [ $? -ne 0 ]; then
    echo "集成测试运行失败！"
    exit 1
fi

echo
echo "========================================"
echo "所有测试运行完成！"
echo "========================================"
echo
echo "测试结果总结："
echo "- 完整测试套件: 通过"
echo "- 事务失效专项测试: 通过"
echo "- 服务层单元测试: 通过"
echo "- 控制器测试: 通过"
echo "- 依赖服务测试: 通过"
echo "- 集成测试: 通过"
echo
echo "测试报告位置: target/surefire-reports/"
echo
